1 <?php
2 session_start();
// Use session variable on this page. This function must put on the top of page.
3 if
(!isset($_SESSION['username']) || $_SESSION['usertype'] !='admin'){ // if session variable "username" does not exist.
4 header(
"location:index.php?msg=Please%20login%20to%20access%20admin%20area%20!"); // Re-direct to index.php
5 }

6 else

7 {

8 if
(isset($_GET['from_stock_sales_date']) && isset($_GET['to_stock_sales_date']) && $_GET['from_stock_sales_date']!='' && $_GET['to_stock_sales_date']!='' )
9 {
10     include_once
"db.php";
11     error_reporting (E_ALL ^ E_NOTICE);
12             $selected_date=$_GET[
'from_stock_sales_date'];
13             $selected_date=strtotime( $selected_date );
14             $mysqldate = date(
'Y-m-d H:i:s', $selected_date );
15 $fromdate=$mysqldate;
16             $selected_date=$_GET[
'to_stock_sales_date'];
17             $selected_date=strtotime( $selected_date );
18             $mysqldate = date(
'Y-m-d H:i:s', $selected_date );
19
20 $todate=$mysqldate;
21
22 ?>
23 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
24 "http:
//www.w3.org/TR/html4/loose.dtd">
25 <html>
26 <head>
27 <title>Purchase Report</title>
28 <meta http-equiv=
"Content-Type" content="text/html; charset=iso-8859-1">
29 </head>
30 <style type=
"text/css" media="print">
31 .hide{display:none}
32 </style>
33 <script type=
"text/javascript">
34 function printpage() {
35 document.getElementById(
'printButton').style.visibility="hidden";
36 window.print();
37 document.getElementById(
'printButton').style.visibility="visible";
38 }
39 </script>
40 <body>
41 <input name=
"print" type="button" value="Print" id="printButton" onClick="printpage()">
42 <table width=
"100%" border="0" cellspacing="0" cellpadding="0">
43   <tr>
44     <td align=
"center">
45       <table width=
"595" border="0" cellspacing="0" cellpadding="0">
46        
47         <tr>
48           <td height=
"30" align="center"><strong>Stock Sales Report </strong></td>
49         </tr>
50         <tr>
51           <td height=
"30" align="center">&nbsp;</td>
52         </tr>
53         <tr>
54           <td align=
"center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
55             <tr>
56               <td align=
"left"><table width="300" border="0" cellspacing="0" cellpadding="0">
57                 <tr>
58                   <td width=
"150"><strong>Total Purchase</strong></td>
59                   <td width=
"150">&nbsp;<?php echo $age = $db->queryUniqueValue("SELECT sum(subtotal) FROM stock_entries where count1=1 AND type='entry' AND date BETWEEN '$fromdate' AND '$todate' ");?></td>
60                 </tr>
61                 <tr>
62                   <td><strong>Paid Amount</strong></td>
63                   <td>&nbsp;<?php echo $age = $db->queryUniqueValue(
"SELECT sum(payment) FROM stock_entries where count1=1 AND type='entry' AND date BETWEEN '$fromdate' AND '$todate' ");?></td>
64                 </tr>
65                 <tr>
66                   <td width=
"150"><strong>Pending Payment </strong></td>
67                   <td width=
"150">&nbsp;<?php echo $age = $db->queryUniqueValue("SELECT sum(balance) FROM stock_entries where count1=1 AND type='entry' AND date BETWEEN '$fromdate' AND '$todate' ");?></td>
68                 </tr>
69               </table></td>
70               <td align=
"right">&nbsp;</td>
71             </tr>
72           </table></td>
73         </tr>
74         <tr>
75           <td width=
"45"><hr></td>
76         </tr>
77         <tr>
78           <td height=
"20"><table width="100%" border="0" cellspacing="0" cellpadding="0">
79               <tr>
80                 <td width=
"45"><strong>From</strong></td>
81                 <td width=
"393">&nbsp;<?php echo $_GET['from_stock_sales_date']; ?></td>
82                 <td width=
"41"><strong>To</strong></td>
83                 <td width=
"116">&nbsp;<?php echo $_GET['to_stock_sales_date']; ?></td>
84               </tr>
85           </table></td>
86         </tr>
87         <tr>
88           <td width=
"45"><hr></td>
89         </tr>
90         <tr>
91           <td><table width=
"100%" border="0" cellspacing="0" cellpadding="0">
92               <tr>
93                 <td width=
"10%"><strong>Date</strong></td>
94                 <td width=
"14%"><strong>Supplier<br>
95                 </strong></td>
96                 <td width=
"14%"><strong>Stock</strong></td>
97                 <td width=
"11%"><strong>Quantity</strong></td>
98                 <td width=
"8%"><strong>Rate</strong></td>
99                 <td width=
"11%"><strong>Opening<br>
100                 Stock</strong></td>
101                 <td width=
"11%"><strong>Closing<br>
102                   Stock</strong></td>
103                 <td width=
"11%"><strong>Total</strong></td>
104               </tr>
105               <tr>
106                 <td>&nbsp;</td>
107                 <td>&nbsp;</td>
108                 <td>&nbsp;</td>
109                 <td>&nbsp;</td>
110                 <td>&nbsp;</td>
111                 <td>&nbsp;</td>
112                 <td>&nbsp;</td>
113                 <td>&nbsp;</td>
114               </tr>
115               <?php
116               $result = $db->query(
"SELECT * FROM stock_entries where type='entry' AND date BETWEEN '$fromdate' AND '$todate' ");
117 while
($line = $db->fetchNextObject($result)) {
118 ?>
119             
120                 <tr>
121                 <td><?php $mysqldate=$line->date;
122         $phpdate = strtotime( $mysqldate );
123         $phpdate = date(
"d/m/Y",$phpdate);
124         echo $phpdate; ?></td>
125                 <td><?php echo $line->stock_supplier_name; ?></td>
126                 <td><?php echo $line->payment; ?></td>
127                 <td><?php echo $line->stock_name; ?></td>
128                 <td><?php echo $line->company_price; ?></td>
129                 <td><?php echo $line->opening_stock; ?></td>
130                 <td><?php echo $line->closing_stock; ?></td>
131                 <td><?php echo $line->total; ?></td>
132               </tr>
133                 
134
135 <?php
136 }
137               ?>
138           </table></td>
139         </tr>
140         <tr>
141           <td>&nbsp;</td>
142         </tr>
143         <tr>
144           <td>&nbsp;</td>
145         </tr>
146     </table></td>
147   </tr>
148 </table>
149
150 </body>
151 </html>
152 <?php
153 }

154 else

155 echo
"Please from and to date to process report";
156 }
157 ?>


Gõ tìm kiếm nhanh...